/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sys.donto.telas;

/**
 *
 * @author JOABB
 */
public class telaContasPagar extends javax.swing.JDialog {

    /**
     * Creates new form telaContasPagar
     */
    public telaContasPagar() {
        setModal(true);
        setLocationRelativeTo(null);
        initComponents();
        setTitle("sysDONTO - Contas a Pagar");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel5 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        tfDataConsulta = new javax.swing.JFormattedTextField();
        jlData = new javax.swing.JLabel();
        jlData1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        tfNome2 = new javax.swing.JTextField();
        tfNome3 = new javax.swing.JTextField();
        jlData2 = new javax.swing.JLabel();
        tfDataConsulta1 = new javax.swing.JFormattedTextField();
        jComboBox2 = new javax.swing.JComboBox();
        jlData3 = new javax.swing.JLabel();
        tfCidade = new javax.swing.JTextField();
        btPesquisarCidade = new javax.swing.JButton();
        btAdicionarCidade = new javax.swing.JButton();
        jlData4 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jlData5 = new javax.swing.JLabel();
        Fundo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel5.setText("Valor R$");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(480, 160, 52, 15);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel3.setText("Contas a Pagar");
        jLabel3.setFocusable(false);
        getContentPane().add(jLabel3);
        jLabel3.setBounds(210, 50, 179, 29);

        tfDataConsulta.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        try {
            tfDataConsulta.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfDataConsulta.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tfDataConsultaFocusLost(evt);
            }
        });
        getContentPane().add(tfDataConsulta);
        tfDataConsulta.setBounds(210, 230, 120, 20);

        jlData.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jlData.setText("Caso Funcionário ou Dentista");
        getContentPane().add(jlData);
        jlData.setBounds(210, 110, 157, 15);

        jlData1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jlData1.setText("Vencimento");
        getContentPane().add(jlData1);
        jlData1.setBounds(210, 210, 72, 15);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Funcionário", "Dentista", "Outros" }));
        getContentPane().add(jComboBox1);
        jComboBox1.setBounds(20, 130, 170, 20);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel6.setText("Descrição");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(20, 160, 57, 15);

        tfNome2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfNome2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNome2ActionPerformed(evt);
            }
        });
        getContentPane().add(tfNome2);
        tfNome2.setBounds(480, 180, 180, 20);

        tfNome3.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfNome3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNome3ActionPerformed(evt);
            }
        });
        getContentPane().add(tfNome3);
        tfNome3.setBounds(20, 180, 450, 20);

        jlData2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jlData2.setText("Data Pagamento");
        getContentPane().add(jlData2);
        jlData2.setBounds(350, 210, 103, 15);

        tfDataConsulta1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        try {
            tfDataConsulta1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfDataConsulta1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tfDataConsulta1FocusLost(evt);
            }
        });
        getContentPane().add(tfDataConsulta1);
        tfDataConsulta1.setBounds(350, 230, 120, 20);

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Dinheiro", "Cheque", "Cartão", "Deposito" }));
        getContentPane().add(jComboBox2);
        jComboBox2.setBounds(20, 230, 170, 20);

        jlData3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jlData3.setText("Observações");
        getContentPane().add(jlData3);
        jlData3.setBounds(20, 260, 76, 15);

        tfCidade.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfCidade.setEnabled(false);
        tfCidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfCidadeActionPerformed(evt);
            }
        });
        getContentPane().add(tfCidade);
        tfCidade.setBounds(210, 130, 390, 20);

        btPesquisarCidade.setBackground(new java.awt.Color(0, 153, 153));
        btPesquisarCidade.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btPesquisarCidade.setForeground(new java.awt.Color(255, 255, 255));
        btPesquisarCidade.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/donto/imagens/Search 16.png"))); // NOI18N
        btPesquisarCidade.setToolTipText("Pesquisar Estado");
        btPesquisarCidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPesquisarCidadeActionPerformed(evt);
            }
        });
        getContentPane().add(btPesquisarCidade);
        btPesquisarCidade.setBounds(600, 130, 30, 20);

        btAdicionarCidade.setBackground(new java.awt.Color(0, 153, 153));
        btAdicionarCidade.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btAdicionarCidade.setForeground(new java.awt.Color(255, 255, 255));
        btAdicionarCidade.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/donto/imagens/add-16.png"))); // NOI18N
        btAdicionarCidade.setToolTipText("Cadastrar Estado");
        btAdicionarCidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAdicionarCidadeActionPerformed(evt);
            }
        });
        getContentPane().add(btAdicionarCidade);
        btAdicionarCidade.setBounds(630, 130, 30, 20);

        jlData4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jlData4.setText("Forma de Pagamento");
        getContentPane().add(jlData4);
        jlData4.setBounds(20, 210, 130, 15);
        getContentPane().add(jTextField1);
        jTextField1.setBounds(20, 280, 640, 80);

        jlData5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jlData5.setText("Fornecedor");
        getContentPane().add(jlData5);
        jlData5.setBounds(20, 110, 68, 15);

        Fundo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/donto/imagens/telaM.jpg"))); // NOI18N
        getContentPane().add(Fundo);
        Fundo.setBounds(0, 0, 740, 430);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tfDataConsultaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDataConsultaFocusLost
        if(Util.dataValida(tfDataConsulta.getText().toString())== false){
            JOptionPane.showMessageDialog(rootPane, "Data Inválida, redigite!", "ERRO", JOptionPane.ERROR_MESSAGE);
            tfDataConsulta.setText("");
        }
    }//GEN-LAST:event_tfDataConsultaFocusLost

    private void tfNome2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNome2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfNome2ActionPerformed

    private void tfNome3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNome3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfNome3ActionPerformed

    private void tfDataConsulta1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDataConsulta1FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_tfDataConsulta1FocusLost

    private void tfCidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfCidadeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfCidadeActionPerformed

    private void btPesquisarCidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPesquisarCidadeActionPerformed
        CidadeDAO dao = new CidadeDAO();
        List<Cidade> lista = dao.listar();
        CidadeTableModel ctm = new CidadeTableModel(lista);
        Object o = telaPesquisa.exibeTela(ctm, "cidade");
        Cidade cid;
        if (o != null) {
            cid = dao.pesquisaId(Integer.valueOf(String.valueOf(o)));
            paciente.setCidade(cid);
            tfCidade.setText(cid.getDescricao());
        }       // TODO add your handling code here:
    }//GEN-LAST:event_btPesquisarCidadeActionPerformed

    private void btAdicionarCidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAdicionarCidadeActionPerformed
        telaCidade tc = new telaCidade();
        tc.setVisible(true);        // TODO add your handling code here:
    }//GEN-LAST:event_btAdicionarCidadeActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(telaContasPagar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(telaContasPagar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(telaContasPagar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(telaContasPagar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new telaContasPagar().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Fundo;
    private javax.swing.JButton btAdicionarCidade;
    private javax.swing.JButton btPesquisarCidade;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JLabel jlData;
    private javax.swing.JLabel jlData1;
    private javax.swing.JLabel jlData2;
    private javax.swing.JLabel jlData3;
    private javax.swing.JLabel jlData4;
    private javax.swing.JLabel jlData5;
    private javax.swing.JTextField tfCidade;
    private javax.swing.JFormattedTextField tfDataConsulta;
    private javax.swing.JFormattedTextField tfDataConsulta1;
    private javax.swing.JTextField tfNome2;
    private javax.swing.JTextField tfNome3;
    // End of variables declaration//GEN-END:variables
}
